package com.burgeon.backend.EnterpriseWeChat.controller;

import com.burgeon.backend.EnterpriseWeChat.entity.*;
import com.burgeon.backend.EnterpriseWeChat.service.EWAnalysisService;
import com.burgeon.backend.EnterpriseWeChat.service.EWBrandService;
import com.burgeon.backend.EnterpriseWeChat.utils.ImageUrl;
import com.burgeon.backend.stsutil.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.*;
import java.util.ArrayList;
import java.util.HashMap;

@RestController
@CrossOrigin
@RequestMapping("ewapp/analysis")
public class EWAnslysisController extends EWBaseController {
    @Autowired
    private EWAnalysisService ewAnalysisService;

    /**
     * 概况报告
     * @param token
     * @return
     */
    @RequestMapping("getVipRate")
    public ResponseResult<VipRate> getVipRate(String token, String storeId){
        VipRate data = ewAnalysisService.getVipRate(token,storeId);
        return new ResponseResult<>(SUCCESS,data);
    }

    /**
     * 数据图表
     * @param token
     * @param storeId
     * @return
     */
    @RequestMapping("getChartData")
    public ResponseResult<ArrayList<ChartSurvey>> getChartData(String token, String storeId){
        ArrayList<ChartSurvey> data = ewAnalysisService.getChartData(token,storeId);
        return new ResponseResult<>(SUCCESS,data);
    }

    /**
     * 店铺KPI
     * @param token
     * @param storeId
     * @return
     */
    @RequestMapping("getStoreKpi")
    public ResponseResult<HashMap> getStoreKpi(String token, String storeId,String type){
        HashMap data = ewAnalysisService.getStoreKpi(token,storeId,type);
        return new ResponseResult<>(SUCCESS,data);
    }

    /**
     * 会员升降级记录
     * @param token
     * @param storeId
     * @param content
     * @param page
     * @return
     */
    @RequestMapping("getVipRelegation")
    public ResponseResult<ArrayList<VipRelegation>> queryVipRelegation(String token,String storeId, String content, int page){
        ArrayList<VipRelegation> data = ewAnalysisService.queryVipRelegation(token, storeId, content, page);
        return new ResponseResult<>(SUCCESS,data);
    }

    /**
     * RFIM占比
     * @param token
     * @param storeId
     * @return
     */
    @RequestMapping("getRfimData")
    public ResponseResult<ArrayList<RFIM>> getRfimData(String token,String storeId){
        ArrayList<RFIM> data = ewAnalysisService.getRfimData(token, storeId);
        return new ResponseResult<>(SUCCESS,data);
    }

    /**
     * 同环比
     * @param token
     * @param empId
     * @return
     */
    @RequestMapping("getStoreCRM")
    public ResponseResult<HashMap<String, ArrayList<String>>> getStoreCRM(String token, String empId){
        HashMap<String, ArrayList<String>> data = ewAnalysisService.getStoreCRM(token,empId);
        return new ResponseResult<>(SUCCESS,data);
    }

    /**
     * 同环比具体数据
     * @param token
     * @param empId
     * @return
     */
    @RequestMapping("getStoreCRMItems")
    public ResponseResult<ArrayList<StoreCRM>> getStoreCRMItems(String token,String empId){
        ArrayList<StoreCRM> data = ewAnalysisService.getStoreCRMItems(token, empId);
        return new ResponseResult<>(SUCCESS,data);
    }

    /**
     * 会员构成
     * @param token
     * @param storeId
     * @param type
     * @return
     */
    @RequestMapping("getVipData")
    public ResponseResult<ArrayList<VipData>> getVipData(String token,String storeId,String type){
        ArrayList<VipData> data = ewAnalysisService.getVipTypeData(token, storeId,type);
        return new ResponseResult<>(SUCCESS,data);
    }


}
